package com.jeasonzhao.commons.parser.lex;

public final class CharCollection extends java.util.Vector<Character>
{
    private static final long serialVersionUID = 1L;
    public static CharCollection from(String str)
    {
        return null == str ? null : from(str.toCharArray());
    }

    public static CharCollection from(char ...arys)
    {
        if(null == arys)
        {
            return null;
        }
        CharCollection ret = new CharCollection();
        for(int n = 0;n < arys.length;n++)
        {
            ret.addElement(arys[n]);
        }
        return ret;
    }

    public boolean contains(char c)
    {
        return super.contains(Character.valueOf(c));
    }

    public boolean contains(Character c)
    {
        return super.contains(c);
    }

    public String toString()
    {
        return toString(null,false);
    }

    public String toString(final String str,final boolean appendAtFirst)
    {
        final StringBuffer strRet = new StringBuffer();
        for(int n = 0;n < this.size();n++)
        {
            if(str != null && (n > 0 || appendAtFirst))
            {
                strRet.append(str);
            }
            strRet.append(this.elementAt(n));
        }
        return strRet.toString();
    }
}
